﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PO_2011;

namespace WindowsFormsApplication1
{
    public partial class Binarization : Form
    {
        private Pnm p;
        public Form1 refToMainWindow;
        public bool TypWygladzania;
        float value = 0;
        private Bitmap actualBitmap;

        public Binarization(Pnm objectPnm)
        {
            InitializeComponent();
            p = objectPnm;

            actualBitmap = new Bitmap(p.getBitmap());
            pictureBox1.Size = new System.Drawing.Size(p.GetWidth, p.GetHeight);
            this.ClientSize = new System.Drawing.Size(p.GetWidth + 250, p.GetHeight + 150);
            pictureBox1.Image = p.getBitmap(); 
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.refToMainWindow.pictureBox1.Image = p.BitmapFiltr;
            p.bitmap = p.BitmapFiltr;
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            value = trackBar1.Value;
            pictureBox1.Image = p.Binaryzacja(value,actualBitmap);
        }
    }
}
